#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>

//https://leetcode.cn/problems/largest-number-at-least-twice-of-others/

int dominantIndex(int* nums, int numsSize){
    int max = 0;
    int less = 1;
    for (int i = 1; i < numsSize; i++) {
        if (nums[i] > nums[max]) {
            less = max;
            max = i;
        } else if (nums[i] >nums[less]) {
            less = i;
        }
    }
    if (nums[max] >= nums[less] * 2) {
        return max;
    } else {
        return -1;
    }
}

int main() {
    int arr[4] = {0, 0, 3, 2};
    int a = dominantIndex(arr, 4);
    printf("%d", a);
    return 0;
}